package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class ValidationCollection extends CollectionBase {
   private Worksheet b;
   private int c = -1;

   Worksheet a() {
      return this.b;
   }

   ValidationCollection(Worksheet sheet) {
      this.b = sheet;
   }

   int a(Validation var1) {
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
      return this.getCount() - 1;
   }

   /** @deprecated */
   public int add() {
      Validation var1 = new Validation(this);
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
      return this.getCount() - 1;
   }

   public int add(CellArea ca) {
      Validation var2 = new Validation(this);
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var2);
      com.aspose.cells.b.a.a.ze.a(var2.a, (Object)ca);
      return this.getCount() - 1;
   }

   public int add(Validation validation) {
      for(int var2 = 0; var2 < validation.getAreaList().size(); ++var2) {
         CellArea var3 = (CellArea)validation.getAreaList().get(var2);
         this.removeArea(var3);
      }

      com.aspose.cells.b.a.a.ze.a(this.a, (Object)validation);
      return this.getCount() - 1;
   }

   public Validation get(int index) {
      return (Validation)this.a.get(index);
   }

   public void removeACell(int row, int column) {
      Iterator var3 = this.iterator();

      while(var3.hasNext()) {
         Validation var4 = (Validation)var3.next();
         var4.removeACell(row, column);
      }

   }

   public void removeArea(CellArea ca) {
      for(int var2 = 0; var2 < this.getCount(); ++var2) {
         Validation var3 = this.get(var2);
         var3.removeArea(ca);
         if (var3.getAreaList().size() <= 0) {
            this.removeAt(var2--);
         }
      }

   }

   void a(CellArea var1, Validation var2) {
      for(int var3 = 0; var3 < this.getCount(); ++var3) {
         Validation var4 = this.get(var3);
         var4.removeArea(var1);
         if (var4 != var2 && var4.getAreaList().size() <= 0) {
            this.removeAt(var3--);
         }
      }

   }

   public Validation getValidationInCell(int row, int column) {
      for(int var3 = 0; var3 < this.getCount(); ++var3) {
         Validation var4 = this.get(var3);

         for(int var5 = 0; var5 < var4.getAreaList().size(); ++var5) {
            CellArea var6 = (CellArea)var4.getAreaList().get(var5);
            if (row >= var6.StartRow && row <= var6.EndRow && column >= var6.StartColumn && column <= var6.EndColumn) {
               return var4;
            }
         }
      }

      return null;
   }

   void a(ValidationCollection var1, CopyOptions var2) {
      for(int var3 = 0; var3 < var1.getCount(); ++var3) {
         Validation var4 = var1.get(var3);
         Validation var5 = new Validation(this);
         var5.a(var4, var2);
         this.a(var5);
      }

      this.c = var1.c;
   }

   private void d() {
      int var1 = 0;
      int var2 = 0;

      int[] var6;
      for(Iterator var3 = this.iterator(); var3.hasNext(); var2 = var6[0]) {
         Validation var4 = (Validation)var3.next();
         int[] var5 = new int[]{var1};
         var6 = new int[]{var2};
         var4.a(var5, var6);
         var1 = var5[0];
      }

   }

   void a(ValidationCollection var1, int var2, int var3, int var4, CopyOptions var5) {
      this.d();

      for(int var6 = 0; var6 < var1.getCount(); ++var6) {
         Validation var7 = var1.get(var6);
         int var8 = var7.getAreaList().size();

         for(int var9 = 0; var9 < var8; ++var9) {
            CellArea var10 = (CellArea)var7.getAreaList().get(var9);
            Object var11 = zayd.b(var10, var2, var4);
            if (var11 != null) {
               var10 = (CellArea)var11;
               CellArea var12 = new CellArea();
               var12.StartRow = var3;
               var12.StartColumn = var10.StartColumn;
               var12.EndRow = var10.EndRow - var10.StartRow + var12.StartRow;
               var12.EndColumn = var10.EndColumn;
               if (var1 == this) {
                  zayd.a(var7.getAreaList(), var12);
               } else {
                  Validation var13 = new Validation(this);
                  var13.a(var7, var12, this.b, var5);
                  com.aspose.cells.b.a.a.ze.a(this.a, (Object)var13);
               }
            }
         }
      }

   }

   void b(ValidationCollection var1, int var2, int var3, int var4, CopyOptions var5) {
      this.d();

      for(int var6 = 0; var6 < var1.getCount(); ++var6) {
         Validation var7 = var1.get(var6);
         int var8 = var7.getAreaList().size();

         for(int var9 = 0; var9 < var8; ++var9) {
            CellArea var10 = (CellArea)var7.getAreaList().get(var9);
            Object var11 = zayd.c(var10, var2, var4);
            if (var11 != null) {
               var10 = (CellArea)var11;
               CellArea var12 = new CellArea();
               var12.StartRow = var10.StartRow;
               var12.EndRow = var10.EndRow;
               var12.StartColumn = var3;
               var12.EndColumn = var10.EndColumn - var10.StartColumn + var3;
               if (var1 == this) {
                  zayd.a(var7.getAreaList(), var12);
               } else {
                  Validation var13 = new Validation(this);
                  var13.a(var7, var12, this.b, var5);
                  com.aspose.cells.b.a.a.ze.a(this.a, (Object)var13);
               }
            }
         }
      }

   }

   void a(ValidationCollection var1, CellArea var2, CellArea var3, CopyOptions var4, boolean var5) {
      if (!var5) {
         boolean var10000 = var1 == this;
         this.d();

         for(int var7 = 0; var7 < var1.getCount(); ++var7) {
            Validation var8 = var1.get(var7);
            int var9 = var8.getAreaList().size();

            for(int var10 = 0; var10 < var9; ++var10) {
               CellArea var11 = (CellArea)var8.getAreaList().get(var10);
               Object var12 = zayd.e(var11, var2);
               if (var12 != null) {
                  var11 = (CellArea)var12;
                  CellArea var13 = new CellArea();
                  var13.StartRow = var11.StartRow - var2.StartRow + var3.StartRow;
                  var13.StartColumn = var11.StartColumn - var2.StartColumn + var3.StartColumn;
                  var13.EndRow = var11.EndRow - var11.StartRow + var13.StartRow;
                  var13.EndColumn = var11.EndColumn - var11.StartColumn + var13.StartColumn;
                  if (var1 == this) {
                     zayd.a(var8.getAreaList(), var13);
                  } else {
                     Validation var14 = new Validation(this);
                     var14.a(var8, var13, this.b, var4);
                     com.aspose.cells.b.a.a.ze.a(this.a, (Object)var14);
                  }
               }
            }
         }

      }
   }

   void a(CellArea var1, int var2, int var3, Worksheet var4, boolean var5) {
      WorksheetCollection var6 = this.b.c();

      for(int var7 = 0; var7 < this.getCount(); ++var7) {
         Validation var8 = this.get(var7);
         if (var8.getAreaList() != null && var8.getAreaList().size() != 0) {
            int var9 = var8.getAreaList().size();
            byte var10 = 0;
            byte var11 = 0;
            int[] var12 = new int[]{var10};
            int[] var13 = new int[]{var11};
            var8.a(var12, var13);
            int var18 = var12[0];
            int var19 = var13[0];
            boolean var14 = var8.f();
            ArrayList var15 = new ArrayList();
            ArrayList var16 = new ArrayList();
            switch(var3) {
            case 0:
               zayd.a(var8.getAreaList(), var6.n().j(), var1, var2, var15, var16);
               break;
            case 1:
               zayd.c(var8.getAreaList(), var6.n().j(), var1, var2, var15, var16);
            case 2:
            default:
               break;
            case 3:
               zayd.d(var8.getAreaList(), var6.n().j(), var1, var2, var15, var16);
               break;
            case 4:
               zayd.b(var8.getAreaList(), var6.n().j(), var1, var2, var15, var16);
            }

            if (var14) {
               var8.getAreaList().clear();
               if (var15.size() != 0) {
                  com.aspose.cells.b.a.a.ze.a(var8.getAreaList(), (Collection)var15);
                  this.a(false, var8, var1, var2, var3, var4, var5, var18, var19);
               }

               if (var16.size() != 0) {
                  if (var15.size() != 0) {
                     Validation var17 = new Validation(this);
                     var17.a(var8);
                     var8 = var17;
                     this.a.add(var7, var17);
                     ++var7;
                  }

                  com.aspose.cells.b.a.a.ze.a(var8.getAreaList(), (Collection)var16);
                  int[] var20 = var8.b();
                  var18 = var20[0];
                  var19 = var20[1];
                  this.a(true, var8, var1, var2, var3, var4, var5, var18, var19);
               }
            } else {
               var8.getAreaList().clear();
               com.aspose.cells.b.a.a.ze.a(var8.getAreaList(), (Collection)var15);
               com.aspose.cells.b.a.a.ze.a(var8.getAreaList(), (Collection)var16);
               this.a(false, var8, var1, var2, var3, var4, var5, var18, var19);
            }
         }
      }

   }

   private void a(boolean var1, Validation var2, CellArea var3, int var4, int var5, Worksheet var6, boolean var7, int var8, int var9) {
      int var10 = var8;
      int var11 = var9;
      if (var1) {
         switch(var5) {
         case 0:
            var10 = var8 - var4;
            break;
         case 1:
            var11 = var9 + var4;
         case 2:
         default:
            break;
         case 3:
            var11 = var9 - var4;
            break;
         case 4:
            var10 = var8 + var4;
         }
      }

      byte[] var12;
      if (var2.b != null) {
         var12 = var2.b;
         zyo.a(var3, var4, var5, var6, var7, var12, 0, var12.length - 1, var10, var11, var8, var9);
         var2.b = var12;
      }

      if ((var2.getOperator() == 0 || var2.getOperator() == 7) && var2.c != null) {
         var12 = var2.c;
         zyo.a(var3, var4, var5, var6, var7, var12, 0, var12.length - 1, var10, var11, var8, var9);
         var2.c = var12;
      }

   }

   void a(int var1, int var2) {
      if (var2 != 0) {
         Iterator var3 = this.iterator();

         while(var3.hasNext()) {
            Validation var4 = (Validation)var3.next();
            var4.a(var1, var2, this.b);
         }

      }
   }

   void b(int var1, int var2) {
      if (var2 != 0) {
         Iterator var3 = this.iterator();

         while(var3.hasNext()) {
            Validation var4 = (Validation)var3.next();
            var4.b(var1, var2, this.b);
         }

      }
   }

   int b() {
      return this.c;
   }

   void a(int var1) {
      this.c = var1;
   }

   boolean c() {
      if (this.c != -1) {
         return true;
      } else if (this.getCount() == 0) {
         return false;
      } else {
         String var1 = this.b.getActiveCell();
         byte var2 = 0;
         byte var3 = 0;
         int[] var4 = new int[]{var2};
         int[] var5 = new int[]{var3};
         CellsHelper.a(var1, var4, var5);
         int var11 = var4[0];
         int var12 = var5[0];
         Iterator var6 = this.iterator();

         while(true) {
            ArrayList var8;
            do {
               do {
                  Validation var7;
                  do {
                     do {
                        if (!var6.hasNext()) {
                           return false;
                        }

                        var7 = (Validation)var6.next();
                     } while(var7.getType() != 3);
                  } while(!var7.getInCellDropDown());

                  var8 = var7.getAreaList();
               } while(var8 == null);
            } while(var8.size() == 0);

            Iterator var9 = var8.iterator();

            while(var9.hasNext()) {
               CellArea var10 = (CellArea)var9.next();
               if (var11 >= var10.StartRow && var11 <= var10.EndRow && var12 >= var10.StartColumn && var12 <= var10.EndColumn) {
                  return true;
               }
            }
         }
      }
   }

   void a(byte[] var1) {
      int var2 = com.aspose.cells.b.a.zc.a(var1, 10);
      if (var2 != -1) {
         this.b.getShapes().e(var2);
         this.c = -1;
      }

   }
}
